package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sjqn
 * @date 2023/11/19
 */
@RestController
@RequestMapping("/alert-data")
@Api(tags = "管理端 - 报警数据相关接口")
public class AlertDataController {

    @Autowired
    private AlertDataService alertDataService;

    @GetMapping("/pageQuery")
    @ApiOperation(value = "分页查询报警数据")
    public ResponseResult<PageResponse<AlertDataVo>> pageQuery(AlertDataPageQueryDto alertDataPageQueryDto) {
        return ResponseResult.success(alertDataService.adminPageQuery(alertDataPageQueryDto));
    }

    @PutMapping("/handleAlertData/{id}")
    @ApiOperation("处理设备报警数据")
    public ResponseResult<Void> handleAlertData(@ApiParam(value = "报警数据ID", required = true) @PathVariable("id") Long id,
                                                @RequestBody AlertDataHandleDto alertDataHandleDto) {
        alertDataService.handleAlertData(id, alertDataHandleDto);
        return ResponseResult.success();
    }
}
